﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using ComLib.ConfigService;
using ComLib.ComType;
using ComLib.ComFun;

namespace EXPrinter
{
    public class ExyOption
    {
        /// <summary>
        /// 打印机名称
        /// </summary>
        private string _printer;
        public string Printer
        {
            get { return _printer; }
            set { _printer = value; }
        }
    
        /// <summary>
        /// 模板文件名称
        /// </summary>
        private string _templateFile = "PhotoPrint.ecl";
        public string TemplateFile
        {
            get { return _templateFile; }
            set { _templateFile = value; }
        }

        public void Save()
        {
            IniConfigFile.WriteValue("Printer", Printer);
            IniConfigFile.WriteValue("xmlFile", TemplateFile);
        }

        public void Load()
        {
            _printer = IniConfigFile.IniValue("Printer");
            _templateFile = IniConfigFile.IniValue("xmlFile");
        }

        public override string ToString()
        {
            StringBuilder builder = new StringBuilder("Exy打印选项: ");
            Action<string, object> FillString =
                (string field, object val) =>
                {
                    if (val != null)
                    {
                        builder.Append("[");
                        builder.Append(field);
                        builder.Append("]: ");
                        builder.Append(val.ToString() + "; ");
                    }                 
                };
            FillString("打印机名称", Printer);
            FillString("模板文件", TemplateFile);           
            return builder.ToString();
        }
    }
}
